﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MuNet;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            TestClass cfz = new TestClass();
            //ref需要初始化才可以
            int t_ref = 0;
            //outbu不需要初始化
            int t_out = 111;
            //首次函数
            cfz.changeNow(11, ref t_ref, out t_out);
            Console.WriteLine("当前的外部REF是{0}", t_ref);
            Console.WriteLine("当前的外部OUT是{0}", t_out);
            //二次函数
            cfz.changeNow(11, ref t_ref, out t_out);
            Console.WriteLine("当前的外部REF是{0}", t_ref);
            Console.WriteLine("当前的外部OUT是{0}", t_out);
            this.test_str_label.Text = cfz.getNowStr();
            this.test_int_label.Text = t_out.ToString();
            cfz.changeNow(1);

            ///二次测试
            TestClass cfz01 = new TestClass("哈哈哈");
            this.test_str_label.Text = cfz01.getNowPri();

            ///三次测试
            TestClass cfz02 = new TestClass(110);
            this.test_str_label.Text = cfz02.getNowPri();
            Console.WriteLine("cfz02[0]{0}", cfz02[0]);
            cfz02[0] = 110;
            Console.WriteLine("cfz02[0]{0}", cfz02[0]);
            cfz02[1] = 220;

            //四次测试
            TestClass cfz03 = new TestClass();
            this.test_str_label.Text = cfz03.getNowPri();
            Console.WriteLine("现在的PI1是{0}", TestClass.PI.ToString());
            Console.WriteLine("现在的PI2是{0}", cfz03.getPI().ToString());
            Console.WriteLine("现在的PRI是{0}", cfz03.Pri);
            Console.WriteLine("现在的STR1是{0}", cfz03.Str);
            cfz03.Str = "哈哈，我是可写的！~";
            Console.WriteLine("现在的STR2是{0}", cfz03.Str);
            Console.WriteLine("现在的CAN_CHANGE1是{0}", TestClass.CAN_CHANGE.ToString());
            TestClass.CAN_CHANGE = 1;
            Console.WriteLine("现在的CAN_CHANGE2是{0}", TestClass.CAN_CHANGE.ToString());
            if (MuFso.IsFolder("123"))
            {
                Console.WriteLine("123是个目录");
            }
            else
            {
                Console.WriteLine("123不是个目录");
            }
            //FsoHelper fso = new FsoHelper();

            SealedClass sone = new SealedClass();
            SealedClass stwo = new SealedClass();
            Console.WriteLine(SealedClass.isHeq(sone, stwo).ToString());
            sone.CAN_EQ = 110;
            stwo.CAN_EQ = 110;
            Console.WriteLine(SealedClass.isHeq(sone, stwo).ToString());
            Console.WriteLine(sone.getHandMU());

            //五次测试
            cfz03.getFrom(1, 4);
            Console.WriteLine(cfz03.getFrom(1, 4).ToString());

            //六次测试
            int t_out6 = cfz03.getFrom(cfz03.getFrom, 2, 2);
            Console.WriteLine(t_out6.ToString());
            cfz03.seeOne("峰展");
            cfz03.seeOne("燕萍", "我爱你");
            cfz03.seeMe();
            cfz03.seeYou();

            //七次测试
            MuIni ini = new MuIni("F:\\win.ini");
            ini.Set("CFZ", "TIME", "201505082330");
            ini.Set("CFZ", "TIME2", "201505082330");
            ini.Empty("CFZ", "TIME2");
            //ini.Delete("CFZ", "TIME2");
            ini.Delete("files");
            Console.WriteLine(ini.Get("XLServicePlatform_TpLoader", "TpExistenceTime"));
            Console.WriteLine(ini.Get("XLServicePlatform_TpLoader", "TpExistenceTime0"));
            Console.WriteLine(ini.Get("XLServicePlatform_TpLoader0", "TpExistenceTime0"));
            ini.Clear();

            //八次测试
            //测试事件
            CollectionClass cfzColl = new CollectionClass();
            cfzColl.OnChanged += new CollectionClass.CfzHandler(this.coll_Changed);
            cfzColl.OnChanged += new CollectionClass.CfzHandler(this.coll_Changed2);
            //在这里触发事件
            cfzColl.Add(11);
            cfzColl.Add();

            //九次测试
            InterfaceClass cfzInter = new InterfaceClass();
            cfzInter.OnSay += new doSome(this.inter_Say);
            cfzInter.AddString();
            cfzInter.FinialString = "要改变下你这个字符串";
            cfzInter.WriteAll();
            InterClass cfzIt = new InterClass();
            cfzIt.AddNow();
            cfzIt.AddString();
            //顺带测试一下接口实现查询
            //使用as来查询
            Interface5Class t_inter = cfzIt as Interface5Class;
            if (t_inter != null)
            {
                Console.WriteLine("InterClass类实现了接口Interface5Class");
            }
            else
            {
                Console.WriteLine("InterClass类不是接口Interface5Class的实现");
            }
            //使用is来查询，建议使用
            if (cfzInter is Interface5Class)
            {
                Console.WriteLine("InterfaceClass类实现了接口Interface5Class");
            }
            else
            {
                Console.WriteLine("InterfaceClass类不是接口Interface5Class的实现");
            }

            //十次测试
            Console.WriteLine("测试泛型：{0}", cfz.getLink<int>(11, 22));
            Console.WriteLine("测试泛型：{0}", cfz.getLink<string>("寂寞", "空虚"));

            MuConfig my_cfg = new MuConfig();

            my_cfg.Add("CFG001", "123");
            my_cfg.Add("CFG002", "120");


            //读取配置
            int t_cfg = my_cfg.Get<int>("CFG001", 110);
            Console.WriteLine("当前的CFG001配置是:{0}", t_cfg);
        }

        /// <summary>
        /// CollectionClass数字变化事件1
        /// </summary>
        /// <param name="sender"></param>
        private void coll_Changed(object sender)
        { 
            CollectionClass that = (CollectionClass)sender;
            Console.WriteLine("现在CollectionClass的数值是：" + that.NowInt.ToString());
        }

        /// <summary>
        /// CollectionClass数字变化事件2
        /// </summary>
        /// <param name="sender"></param>
        private void coll_Changed2(object sender)
        {
            CollectionClass that = (CollectionClass)sender;
            Console.WriteLine("再看一下现在CollectionClass的数值是：" + that.NowInt.ToString());
        }

        /// <summary>
        /// InterfaceClass内部的对话变化
        /// </summary>
        /// <param name="p_out"></param>
        private void inter_Say(string p_out)
        {
            Console.WriteLine("里头说点啥呢：" + p_out);
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}
